package com.wltt.product.frfront.holder;

import com.sun.webkit.dom.HTMLButtonElementImpl;
import com.sun.webkit.dom.HTMLDocumentImpl;
import com.sun.webkit.dom.HTMLInputElementImpl;
import javafx.scene.web.WebView;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class JavafxHolder {

    /**
     * 浏览器
     */
    private static WebView webView;

    public static WebView getWebView() {
        return webView;
    }

    public static void setWebView(WebView webView) {
        JavafxHolder.webView = webView;
    }

    /**
     * 设置开始焊接按钮是否教你用
     *
     * @param id 开始按钮页面id
     * @param isDisabled 是否禁用，true禁用，false不禁用
     * @return
     */
    public static void setStartWeldDisable(String id, boolean isDisabled) {
        try {
            Document doc = JavafxHolder.getWebView().getEngine().getDocument();
            Element element = ((HTMLDocumentImpl) doc).querySelector("#pane-Direct > div > div.flex.mt20 > div.flex.flex-box.flex1.itemEnd.width100.mr8 > button:nth-child(2)");
            HTMLButtonElementImpl buttonElement = (HTMLButtonElementImpl) element;
            buttonElement.setDisabled(isDisabled);
        } catch (Exception e) {
        }
    }
}
